<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">{{name.firstName}}</div>
    <script>
        function getValueBypath(obj, path) {
            const paths = path.split('.');
            let prop;
            let value = obj;
            while (prop = paths.shift()) {
                console.log('prop', prop);
                value = value[prop];
            }
            return value;
        }
        const root = document.getElementById('root');
        document.getElementById('root').innerText = getValueBypath({name: {firstName: 'tianrui'}}, 'name.firstName');
        
    </script>
</body>
</html>